# ADS78 Test Build File

if meson_build
    drivers_install_dir = meson.project_build_root() / 'opt/bmc/drivers'
    run_command('mkdir', '-p', drivers_install_dir, check: false)
else
    drivers_install_dir = 'opt/bmc/drivers/'
endif

# ADS78 I2cStub library source files
i2c_stub_sources = [
  '../../bus/i2c/drivers/i2c.cpp',
]

# Create ADS78 I2cStub shared library
i2c_stub_lib = shared_library(
  'I2cStub',
  i2c_stub_sources,
  include_directories: [
    include_directories('../../../../drivers/bus/i2c'),
    include_directories('../../../../drivers/internal'),
    include_directories('../../../../tests/drivers/bus/i2c'),
    include_directories('../../../../include'),
    include_directories('../../../../gen'),
  ],
  dependencies: [libmcpp_deps, internal_dep],
  install: false
)

# Create ADS78 I2cStub dependency
i2c_stub_dep = declare_dependency(
  link_with: i2c_stub_lib,
  include_directories: [
    include_directories('../../../../drivers/bus/i2c'),
    include_directories('../../../../drivers/internal'),
    include_directories('../../../../tests/drivers/bus/i2c'),
    include_directories('../../../../include'),
    include_directories('../../../../gen'),
  ],
  dependencies: [libmcpp_deps],
)

ads78_test_sources = [
  '../../../main.cpp',
  'test_ads78_abi.cpp',
] + chip_interface_sources

ads78_test = executable(
  'test_ads78_abi',
  ads78_test_sources,
  include_directories: [
    include_directories('.'),
    include_directories('../../../..'),
    include_directories('../../../../drivers/bus/i2c'),
    include_directories('../../../../drivers/chip/ads78'),
    include_directories('../../../../drivers/chip'),
    include_directories('../../../../drivers/internal'),
    include_directories('../../../../tests/drivers/bus/i2c'),
    include_directories('../../../../include'),
    include_directories('../../../../gen'),
  ],
  dependencies: [
    gtest_dep,
    test_utilities_dep,
    test_utils_dep,
    i2c_stub_dep,
    internal_dep,
    ads78_dep,
    i2c_dep,
  ],
  cpp_args: ['-UHAVE_LIBSOC_ADAPTER'],
  link_with: [],
  install: false,
)

test('test_ads78_abi', ads78_test, timeout: 300, suite: 'ads78')

# ADS78 单元测试
ads78_unit_test_sources = [
  '../../../main.cpp',
  'test_ads78.cpp',
]

ads78_unit_test = executable(
  'test_ads78',
  ads78_unit_test_sources,
  include_directories: [
    include_directories('.'),
    include_directories('../../../..'),
    include_directories('../../../../drivers/internal/chip/chip_ads78'),
    include_directories('../../../../drivers/internal/chip/chip_base'),
    include_directories('../../../../drivers/internal/bus/bus_base'),
    include_directories('../../../../drivers/internal'),
    include_directories('../../../../include'),
    include_directories('../../../../gen'),
  ],
  dependencies: [
    gtest_dep,
    test_utilities_dep,
    test_utils_dep,
    libmcpp_deps,
    internal_dep,
  ],
  cpp_args: ['-DUNIT_TEST'],
  install: false,
  link_whole: [internal_static_lib],
)

test('test_ads78', ads78_unit_test, timeout: 300, suite: 'ads78')
